﻿using CodeStash.Common.DTOS;
using CodeStash.Common.Enums;

namespace CodeStash.Addin.Core.Interfaces
{
    /// <summary>
    /// The interface describing the REST services thta
    /// are accessed from the addin.
    /// </summary>
    public interface IRestService
    {
        /// <summary>
        /// Can the user connect to CodeStash based on the chosen login.
        /// </summary>
        /// <param name="loginDetails"></param>
        /// <returns>True if the user can connect, false otherwise.</returns>
        bool CanConnectToCodeStash(LoginDetails loginDetails);

        /// <summary>
        /// Set the login details.
        /// </summary>
        /// <param name="loginDetails"></param>
        void SetLoginDetails(LoginDetails loginDetails);

        /// <summary>
        /// Gets or sets the page size for the search.
        /// </summary>
        int PageSize { get; set; }

        /// <summary>
        /// Retrieve the groups from the server to be displayed in the dropdown lists.
        /// </summary>
        /// <returns>The group result from the REST service.</returns>
        JSONGroupingResult RetrieveGroups();

        /// <summary>
        /// Retrieve the languages from the server to be displayed in the dropdown lists.
        /// </summary>
        /// <returns>The languages result from the REST service.</returns>
        JSONLanguagesResult RetrieveLanguages();

        /// <summary>
        /// Add the code snippet into CodeStash.
        /// </summary>
        /// <param name="actualCode">The code that will be inserted.</param>
        /// <param name="categoryName">The category name.</param>
        /// <param name="languageId">The id of the selected language.</param>
        /// <param name="language">The selected language.</param>
        /// <param name="tags">Any tags associated with this snippet.</param>
        /// <param name="description">The description of the snippet.</param>
        /// <param name="title">The snippet title.</param>
        /// <param name="groupId">The id of the selected group.</param>
        /// <param name="groupName">The name of the selected group.</param>
        /// <param name="visibility">Who this snippet is visible to.</param>
        /// <returns>The result of adding the snippet.</returns>
        JSONCodeSnippetAddSingleResult AddCodeSnippet(
                string actualCode,
                string categoryName,
                int languageId,
                string language,
                string tags,
                string description,
                string title,
                int? groupId,
                string groupName,
                CodeSnippetVisibility visibility);

        /// <summary>
        /// Search for snippets that match the search criteria.
        /// </summary>
        /// <param name="searchText">The text to search for.</param>
        /// <param name="searchType">The type of the search.</param>
        /// <param name="visibility">Who this snippet is visible to.</param>
        /// <param name="tags">Any tags associated with this snippet.</param>
        /// <param name="pageNumber">The page to search for.</param>
        /// <param name="includeRatings">A boolean value indicating whether snippet rating should be included in search or not.</param>
        /// <param name="rating">Snippet rating to search for</param>
        /// <returns>A single page of search results.</returns>
        JSONPagesSearchResultCodeSnippet Search(
            string searchText, 
            SearchType searchType, 
            CodeSnippetVisibility visibility, 
            string[] tags, 
            int pageNumber,
            bool includeRatings,
            int rating
            );
    }
}
